var app = getApp(),
  common = require("../../common/common.js")

Page({
  data: {

  },
  // 回答老师作业
  addHomeWork(e){
    console.log(e.detail.value.content)
    let _t = this
    let content = e.detail.value.content
    let wid = _t.data.detail.id
    // 学生查看作业详情
    app.util.request({
      url: 'entry/wxapp/submitWork',
      data: {
        wid: wid,
        result: content
      },
      success: function (a) {
        console.log(a.data.errno)
        if (a.data.errno==0){
          wx.showModal({
            title: '提示',
            content: a.data.message ,
            showCancel: true,
            success: function(res) {
              if(res.confirm==true){
                wx.redirectTo({
                  url: '/xc_train/pages/user/user'                  
                })
              }
            }
          })
        }
      }
    })
  },
  onLoad: function (w) {        
    let _t = this
    // 学生查看作业详情
    app.util.request({
      url: 'entry/wxapp/detailWorker',
      data: {
        id:w.id
      },
      success: function (a) {
        console.log(a.data.data)
        _t.setData({
          detail: a.data.data
        })
      }
    })
  },
  onReady: function () {

  },
  onShow: function () {

  },
  onHide: function () {

  },
  onUnload: function () {

  },
  onPullDownRefresh: function () {

  },
  onReachBottom: function () {

  },
  onShareAppMessage: function () {

  }
})